# Maintainer: Jeroen Ooms <jeroenooms@gmail.com>

_realname=rasqal
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=0.9.33
pkgrel=1
pkgdesc="Rasqal RDF Query Library (mingw-w64)"
arch=('any')
url='http://librdf.org/rasqal/'
license=('LICENSE')
source=("http://download.librdf.org/source/${_realname}-${pkgver}.tar.gz")
sha256sums=('6924c9ac6570bd241a9669f83b467c728a322470bf34f4b2da4f69492ccfd97c')

depends=("${MINGW_PACKAGE_PREFIX}-raptor2"
         "${MINGW_PACKAGE_PREFIX}-pcre"
         "${MINGW_PACKAGE_PREFIX}-gmp")

prepare() {
  cd $srcdir/${_realname}-${pkgver}
  > src/win32_rasqal_config.h.in
}

build() {
  cd "$srcdir"/${_realname}-${pkgver}
  [[ -d "${srcdir}"/build-${CARCH} ]] && rm -rf "${srcdir}"/build-${CARCH}
  mkdir -p "${srcdir}"/build-${CARCH} && cd "${srcdir}"/build-${CARCH}
  CFLAGS="-DRASQAL_STATIC -DRAPTOR_STATIC -DPCRE_STATIC" \
  RAPTOR2_LIBS=$(pkg-config --libs --static raptor2) \
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --disable-debug \
    --disable-dependency-tracking

  make
}

package() {
  cd "${srcdir}"/build-${CARCH}
  make install DESTDIR="${pkgdir}"
}
